<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Uploking_packages_m extends MY_Model {

	protected $_table = 'uploking_packages';

	function get_all()
	{
		$this->db->select('uploking_packages.*');

		$this->db->order_by('month', 'DESC');

		return $this->db->get('uploking_packages')->result();
	}

	function get($id)
	{
		return $this->db->select('uploking_packages.*')
					->where(array('uploking_packages.id' => $id))
					->get('uploking_packages')
					->row();
	}
	

	function get_many_by($params = array())
	{

		// Limit the results based on 1 number or 2 (2nd is offset)
		if (isset($params['limit']) && is_array($params['limit']))
			$this->db->limit($params['limit'][0], $params['limit'][1]);
		elseif (isset($params['limit']))
			$this->db->limit($params['limit']);

		return $this->get_all();
	}
	
	function count_by($params = array())
	{
		return $this->db->count_all_results('uploking_packages');
	}

	function update($id, $input)
	{
		return parent::update($id, $input);
	}

	function publish($id = 0)
	{
		return parent::update($id, array('status' => 'live'));
	}

	// -- Archive ---------------------------------------------
}